<template>
  <div class="mod-config">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-select v-model="dataForm.selectshopid" placeholder="校区" style="width:150px;height:50px">
          <el-option v-for="(item, index) in shopids" :label="item.shopName" :key="item.shopName" :value="item.id"></el-option>
        </el-select>
        <div style="float: right">
          <el-input style="width:150px;height:50px" v-model="dataForm.teacher" placeholder="教练姓名" clearable></el-input>
        </div>
        <div style="float: right">
          <el-date-picker
            v-model="dataForm.selDate"
            type="daterange"
            value-format="yyyy-MM-dd"
            align="right"
            unlink-panels
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :picker-options="pickerOptions">
          </el-date-picker>
        </div>
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="dataList" border v-loading="dataListLoading" style="width: 100%;">`
      <el-table-column prop="teacherName" header-align="center" align="center" label="教练姓名" width="200">
      </el-table-column>
      <el-table-column prop="shopId" header-align="center" align="center" label="校区编号" width="200">
      </el-table-column>
      <el-table-column prop="shopName" header-align="center" align="center" label="校区名称" width="200">
      </el-table-column>
      <el-table-column prop="num" header-align="center" align="center" label="课时数" width="200">
      </el-table-column>
      <el-table-column prop="money" header-align="center" align="center" label="课时费" width="200">
      </el-table-column>
      <el-table-column prop="yeji" header-align="center" align="center" label="业绩" width="200">
      </el-table-column>
      <el-table-column prop="ticheng" header-align="center" align="center" label="提成" width="200">
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        dataForm: {
          selDate: [],
          selectshopid: '',
          teacher: ''
        },
        shopids: '',
        dataList: [],
        dataListLoading: false,
        urltoken: this.$cookie.get('token'),
        pickerOptions: {
          shortcuts: [{
            text: '最近一周',
            onClick: function (picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
              picker.$emit('pick', [start, end])
            }
          }, {
            text: '最近一个月',
            onClick: function (picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
              picker.$emit('pick', [start, end])
            }
          }, {
            text: '最近三个月',
            onClick: function (picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
              picker.$emit('pick', [start, end])
            }
          }]
        }
      }
    },
    activated () {
      this.getDataList()
      this.getShopInfo()
    },
    methods: {
      // 获取数据列表
      getDataList () {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/business/sign/queryTeacherCommission'),
          method: 'get',
          params: this.$http.adornParams({
            'start': this.dataForm.selDate[0],
            'end': this.dataForm.selDate[1],
            'teacher': this.dataForm.teacher,
            'shopId': this.dataForm.selectshopid
          })
        }).then(({
          data
        }) => {
          if (data && data.code === 0) {
            this.dataList = data.list // 列表
          } else {
            this.dataList = []
          }
          this.dataListLoading = false
        })
      },
      // 获取分校信息-列表
      getShopInfo () {
        this.$http({
          url: this.$http.adornUrl('/business/student/getShopInfo'),
          mothod: 'get',
          params: {
            'shopId': ''
          }
        }).then(({
          data
        }) => {
          this.shopids = data.list
        })
      }
    }
  }
</script>
